'''
Author: 火红色祥云 809880192@qq.com
Date: 2023-12-26 15:06:18
LastEditors: 火红色祥云 809880192@qq.com
LastEditTime: 2023-12-26 15:06:21
FilePath: /project_luckfox/uart/uart3.py
Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
'''
from periphery import Serial

try:
    serial = Serial(
        "/dev/ttyS3",
        baudrate=115200,
        databits=8,
        parity="none",
        stopbits=1,
        xonxoff=False,
        rtscts=False,
    )

    serial.write(b"Hello World!\n")
    buf = serial.read(128, 1)
    print("Raw data:\n", buf)
    data_strings = buf.decode("utf-8")
    print("Read {:d} bytes, printed as string:\n {:s}".format(len(buf), data_strings))
    
finally:
    serial.close()